{extend name="public:member" /}
{block name="content"}	
<div class="page-header">
		<h1>
			{$breadcrumb1}
			<small>
				<i class="ace-icon fa fa-angle-double-right"></i>
				{$breadcrumb2}
			</small>
			<small>
				<i class="ace-icon fa fa-angle-double-right"></i>
				{$crumbs}
			</small>			
			<button form="form-goods" id="send" type="submit" style="float:right;"  class="btn btn-sm btn-primary">提交</button>			
		</h1>
</div>
	<div class="row">
	<div class="col-xs-12">	
		<div class="panel-body">
        <form action="{$action}" method="post" enctype="multipart/form-data" id="form-goods" class="form-horizontal">
		
			{if condition="$Request.param.id"}
				<input name="id" type="hidden" value="{$Request.param.id}" />
			{/if}
		
          <ul class="nav nav-tabs">
          	
          	<li class="active"><a href="#tab-data" data-toggle="tab">基本信息</a></li>          	
           <!-- <li><a href="#tab-signup" data-toggle="tab">报名项</a></li>  -->          
            <li><a href="#tab-links" data-toggle="tab">分类</a></li>   
                
          </ul>
          <div class="tab-content">
          		
	          	<!-- 基本信息 START -->
	          	<div class="tab-pane active" id="tab-data">
	          		
	          		<div class="form-group required">
		                <label class="col-sm-2 control-label" for="input-image">
		                <span title="" data-toggle="tooltip" data-original-title="上传800x800的图片">缩略图：</span>
		                </label>
		                
		                <div class="col-sm-10" id="thumb">
		                  <a id="thumb-image" href="#" data-toggle="image" class="img-thumbnail">
		                  	
							{if condition="!empty($item['image'])"}	
								<img src="IMG_ROOT<?php echo resize($item['image'],100,100); ?>" />	
							{else /}
								<img src="__PUBLIC__/image/no_image_100x100.jpg" >
							{/if}
								
								</a>
		                  <input type="hidden" name="image" value="{$item.image|default=''}" id="input-image" />
		            </div>
		            
		            </div>   
		            
		            <div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">标题：</label>
						<div class="col-sm-10">
							<input  class="form-control" type="text" value="{$item.title|default=''}" name="title">
						</div>
					</div>
		            
		          
					<div class="form-group">
	                    <label class="col-sm-2 control-label" for="input-description">简介：</label>
	                    <div class="col-sm-10">
	                      <textarea name="data[summary]" class="form-control" rows="5">{$data.summary|default=''}</textarea>	
	                    </div>
                  	</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">联系人：</label>
						<div class="col-sm-10">
							<input  class="form-control" type="text" value="{$item.contact|default=''}" name="contact">
						</div>
					</div>
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">联系电话：</label>
						<div class="col-sm-10">
							<input  class="form-control" type="text" value="{$item.contact_tel|default=''}" name="contact_tel">
						</div>
					</div>
					
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">地点：</label>
						<div class="col-sm-10">
							<input  class="form-control" type="text" value="{$item.location|default=''}" name="location">
						</div>
					</div>
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">名额：</label>
						<div class="col-sm-2">
							<input  class="form-control" type="text" value="{$item.total_num|default=''}" name="total_num">没有限制可不填
						</div>
						
					</div>
				
					
					<div class="form-group required">
						<label class="col-sm-2 control-label" for="input-name2">支付金额：</label>
						<div class="col-sm-2">
							<input  class="form-control" type="text" value="{$item.price|default=''}" name="price">免费则不填
						</div>						
					</div>
					
					<div class="form-group required input-daterange">
						<label class="col-sm-2 control-label" for="input-name2">报名时间：</label>
						<div class="col-sm-3">
							<div class="input-daterange input-group">
								<input class="input-sm form-control" type="text" name="start_apply_time" value="<?php if(isset($item)&&$item['start_apply_time']!=0){echo date('Y-m-d',$item['start_apply_time']);} ?>">
								<span class="input-group-addon">
								<i class="fa fa-arrow-right"></i>
								</span>
								<input class="input-sm form-control" type="text" name="end_apply_time" value="<?php if(isset($item)&&$item['end_apply_time']!=0){echo date('Y-m-d',$item['end_apply_time']);} ?>">
							</div>
							没有限制可不填
						</div>
					</div>
					
					<div class="form-group required input-daterange">
						<label class="col-sm-2 control-label" for="input-name2">活动时间：</label>
						<div class="col-sm-3">
							<div class="input-daterange input-group">
								<input class="input-sm form-control" type="text" name="start_time" value="<?php if(isset($item)&&$item['start_time']!=0){echo date('Y-m-d',$item['start_time']);} ?>">
								<span class="input-group-addon">
								<i class="fa fa-arrow-right"></i>
								</span>
								<input class="input-sm form-control" type="text" name="end_time" value="<?php if(isset($item)&&$item['end_time']!=0){echo date('Y-m-d',$item['end_time']);} ?>">
							</div>
							没有限制可不填
						</div>
					</div>
					
				
					<div class="form-group">
	                    <label class="col-sm-2 control-label" for="input-description">详情：</label>
	                    <div class="col-sm-10">
	                      
	                      <textarea name="data[description]" placeholder="详情" id="description" class="form-control">{$data.description|default=''}</textarea>
	                    </div>
                  	</div>
		            
		           
		            
	          	</div>
	          	<!-- 基本信息 END -->
	          	
	          
	          	<div class="tab-pane" id="tab-signup">						
					
					
	          	</div>
	          	<div class="tab-pane" id="tab-links">						
					<div class="form-group">
					<div class="col-sm-2">
						
						<select id="category" class="form-control" multiple="multiple" name="category" style="height: 400px;">
							{volist name="category" id="c"}
								<option {if condition="isset($item) and $item['cid'] eq $c['id'] "} selected="selected" {/if} value="{$c.id}">{$c.title_show}</option>
							{/volist}
						</select>
						
					</div>
					<div class="col-sm-10 control-label" id="option">
						
					</div>
					</div>
	          	</div>
	          	
	          
          </div>
        </form>
	</div>
	</div>
</div>
{/block}
{block name="javascript"}
 <link rel="stylesheet" href="__ADMIN__/ace/css/datepicker.min.css" />

<link rel="stylesheet" href="__ADMIN__/ace/css/daterangepicker.min.css" />

<script src="__PUBLIC__/js/ckeditor/ckeditor.js"></script> 
<script src="__ADMIN__/ace/js/moment.min.js"></script>
<script src="__ADMIN__/ace/js/bootstrap-datepicker.min.js"></script>

<script src="__ADMIN__/ace/js/bootstrap-datepicker.zh-CN.js"></script>

<script>
	CKEDITOR.replace('description', {
		filebrowserImageUploadUrl: '{:url("member/FileManager/ckupload")}',	
		toolbar: [
					[ 'Source', 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ],
					[ 'FontSize', 'TextColor', 'BGColor' ],
					[ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock','Image','Format']
				]	
	});
	$('.input-daterange').datepicker({
                language: 'zh-CN',
                autoclose: true,
                todayHighlight: true,
                format:'yyyy-mm-dd'
    });
    
$('#category').change(function(){ 
	 $.ajax({
			url: '{:url("Item/get_option_value")}' + '/cid/' + $('#category').val(),
			dataType: 'html',				
			success: function(html) {
				$('#option').html('');
				$('#option').append(html);
			}
		});
});


	
{if condition="isset($item_option)"}	

	$('select[name=\'category\']').trigger('change');	
	
	$("#option").ajaxComplete(function(){ 
		{volist name ="item_option" id="o"}
			Oscshop.setValue("option[{$o.option_id}]", {$o.option_value_id});
		{/volist}
	}); 

{/if}

$('#send').click(function(){
	
	var title=$('input[name="title"]').val();
	
	var category=$('#category').val();
	
	if(title==''){
		alert('标题必填');
		return false;
	}
	if(category==null){
		alert('搜索选项必填');
		return false;
	}
	
	
	return true;
});    
    
</script>
{/block}